fix(windows): resolve file locks and script execution issues#7
Merged
Conversation
- Use .ps1 extension on Windows for PowerShell -File flag compatibility - Use .sh extension on Unix-like systems - Add error context in runInstallScript for better diagnostics - Add TestDownloadToTempFileExtension to verify platform-appropriate extensions Fixes silent failure of 'kairo update' on Windows where PowerShell -File flag could not execute files without .ps1 extension.
- Use 'powershell -ExecutionPolicy Bypass -File' instead of 'cmd /c' - PowerShell scripts (.ps1) cannot be executed by cmd.exe directly - Fix comment check from 'REM' to '#' for PowerShell syntax Fixes TestWrapperScriptExecution failure on Windows where wrapper script was opening in Notepad instead of executing.
- Add defer logger.Close() to auditCmd, auditListCmd, auditExportCmd - Set logger.f = nil after closing to prevent reuse of closed file - Add defer logger.Close() to audit tests - Skip permission test on Windows (chmod behaves differently) Fixes file lock errors in audit tests on Windows where audit.log cannot be deleted after test execution because file was left open.
- ci: update Go version to 1.25.7 in all workflows (fixes GO-2026-4337) - pre-commit: use cmd /c for Windows-native hook execution - task: add pre-commit and pre-commit-install tasks to Taskfile.yml
dkmnx
added a commit
that referenced
this pull request
Feb 9, 2026
…sion fix(windows): resolve file locks and script execution issues
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes Windows compatibility issues related to file handling and script execution in the audit and update commands.
Changes
File Lock Fixes
deferto prevent file locks on Windows (cmd/audit.go)audit.Logger.Close()to nil the file pointer after closing (internal/audit/audit.go)defer logger.Close()calls in audit testsTest Fixes
cmd.exeon Windows (cmd/switch_test.go)#instead ofREM)chmodbehaves differently (cmd/audit_helpers_test.go)Update Command Fixes
.ps1on Windows,.shon Unix) for install scripts (cmd/update.go)Test Plan
Files Changed
cmd/audit.go- Add defer Close() callscmd/audit_helpers_test.go- Skip permission test on Windowscmd/audit_test.go- Add defer Close() callscmd/switch_test.go- Fix PowerShell executioncmd/update.go- Platform-specific temp file extensionscmd/update_test.go- Test temp file extensionsinternal/audit/audit.go- Improve Close() method